from Base import PluginModel, Singleton
import Watcher, VDownload
from include import *
from Plugins import Gernel 



class SampleMgr(PluginModel.PluginModel, Singleton.Singleton, VDownload.DwonloadObserver):
	def __init__(self):
		PluginModel.PluginModel.__init__(self)
		self.files_list = []
	
	def Start(self):
		downloader = VDownload.VDownloader.Instance()
		downloader.AddObserver(self)
		self.watcher = Watcher.Watcher.Instance()
		self.watcher.Start()

	def RegisterPlugins(self):
		self.AddPlugin("Gernel", Gernel.GernelPlugin.Instance(), Gernel.GernelPlugin.Instance().GetData())
		
		
	
		
	def AddSample(self, filename):
		self.files_list.append(filename)
	
	def RemoveSample(self, filename):
		self.files_list.remove(filename)
	

	def OnDownloadComplete(self, md5, bSuccess, filename):
		if (bSuccess):
			self.AddSample(filename)
			param = PluginNotifyParam(FILE_DOWNLOAD_COMPLETE, filename)
			self.NotifyPlugin(param)
		
		
		
		
		
		
	
if __name__ == '__main__':
	mgr = SampleMgr.Instance()
	mgr.RegisterPlugins()
	mgr.Start()
	
		
		
		
		
